﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

using TableTopWidgets;
using System.Threading;

namespace TabletopWidgetTestApp
{
    /// <summary>
    /// Interaction logic for RNTWindow.xaml
    /// </summary>
    
    public partial class RNTWindow : RNTControl
    {
        DemoMenu theMenu;

        public RNTWindow()
        {
            InitializeComponent();

            theMenu = menu;
            image.Height = 270;
        }

        private void revealMenu(Object state)
        {
            theMenu.Visibility = System.Windows.Visibility.Visible;
        }

        //<Image Source="/Images/Hydrangeas.jpg" Margin="0,30,0,0" Height="270" Visibility="Collapsed"/>
        public void RevealImage(string img)
        {
            BitmapImage bpImage = new BitmapImage();

            bpImage.BeginInit();
            bpImage.UriSource = new Uri(@"Images/" +img, UriKind.RelativeOrAbsolute);
            bpImage.DecodePixelWidth = 270;
            bpImage.EndInit();

            image.Source = bpImage;
        }

        private void RNTControl_MouseDown(object sender, MouseButtonEventArgs e)
        {
                double xCoord = e.GetPosition(this).X;
                double yCoord = e.GetPosition(this).Y;

                if (xCoord < 95)
                    xCoord = 95;
                if (xCoord > this.Width - 140)
                    xCoord = this.Width - 140;
                if (yCoord < 150)
                    yCoord = 150;
                if (yCoord > this.Height - 80)
                    yCoord = this.Height - 80;
                Dwell.Start(this, 1000, new TimerCallback(revealMenu));

                theMenu.ChangePosition(xCoord, yCoord);
        }

        private void RNTControl_MouseUp(object sender, MouseButtonEventArgs e)
        {
            Dwell.Stop(this);
        }
    }
}
